/**
 * Created with JetBrains PhpStorm.
 * User: ishowshao
 * Date: 13-3-18
 */
(function (namespace, name) {
    var CheckBoxGroup = function (config) {
        this.config = config || {};
        this.data = config.data || [];
        this.make();
    };
    CheckBoxGroup.prototype = {
        make: function () {
            var that = this;
            var data = this.data;
            this.el = jQuery('<div class="i-check-box-group"></div>');
            for (var i = 0; i < data.length; i++) {
                var checkedAttr = data[i].checked ? 'checked' : '';
                this.el.append('<label><input class="i-check-box-group-input" type="checkbox" name="' + data[i].name + '" value="' + data[i].value + '"' + checkedAttr + '>' + data[i].label + '</label>');
            }
        },
        render: function (renderTo) {
            jQuery(renderTo).append(this.el);
        }
    };
    CheckBoxGroup.prototype.constructor = CheckBoxGroup;

    namespace = namespace || window;
    name = name || 'CheckBoxGroup';

    namespace[name] = CheckBoxGroup;
})(window, 'CheckBoxGroup');
